package com.twu.biblioteca.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA.
 * User: twer
 * Date: 5/16/13
 * Time: 3:58 PM
 * To change this template use File | Settings | File Templates.
 */
public class InputParser {

    public static int parseUserSelect(String select) {
        String regEx = "^\\s*\\d+\\s*$";

        Pattern pattern = Pattern.compile(regEx);
        Matcher matcher = pattern.matcher(select);

        if (!matcher.find()) {
            throw new IllegalArgumentException(Messages.Notify_Message);
        }

        return Integer.parseInt(select);
    }
}
